<%-- 
    Document   : listarmodulos
    Created on : 30-nov-2010, 12:41:35
    Author     : Victor y Karmele
--%>

<%@page import="java.util.MissingResourceException"%>
<%@page import="java.util.ResourceBundle"%>
<%@page import="com.ipartek.formacion.gestformwww.modelo.beans.Curso"%>
<%@page import="com.ipartek.formacion.gestformwww.modelo.beans.Modulo"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.ipartek.formacion.gestformwww.controlador.Verificador"%>
<div class="contenido">
    <div id="submenu">
        <jsp:include page="menumodulo.jsp" flush="true" />
    </div>
    <form name="modulo" action="crear-modulo-accion.do" method="POST">
        <%Curso curso = (Curso) request.getAttribute("visualizacurso");%>
        <input type="hidden" name="idCurso" value="<%=curso.getCurId()%>" />
        <input type="hidden" name="idPestana" value="3" />
        <input type="hidden" name="aleatorioCrearModulo" value="<%=Math.random()%>" />
        <input type="hidden" name="aleatorioBorrarModulo" value="<%=Math.random()%>" />
        <div class="errordatos">
            <% if (request.getAttribute("erroresmodulo") != null) {
                            ResourceBundle bundle = (ResourceBundle) application.getAttribute("errores-mapeo");
                            for (String i : (ArrayList<String>) request.getAttribute("erroresmodulo")) {
                        try {%>
            <%=bundle.getString(i)%><br>
            <%} catch (MissingResourceException ex) {%>
            <%=i%>
            <%}%>
            <%}
                }%>
        </div>
        <table width="100%">
            <tbody>
                <tr>
                    <td width="15%">Descripci&oacute;n: </td>
                    <td width="35%"><input type="text" name="ModDescr" value="" onkeyup="if(!validarCaracteres(this.value)) {this.value=cadenaCorrecta(this.value)}"/></td>
                    <td width="15%">Duraci&oacute;n: </td>
                    <td width="35%"><input type="text" name="ModDur" value="" onkeyup="if(!validarNumero(this.value,false,false)) {this.value=''}"/></td>
                </tr>
            </tbody>
        </table>

        <%boolean linea = true;
                    ArrayList<Modulo> listamodulos = (ArrayList<Modulo>) request.getAttribute("listaModulos");
                    if (listamodulos != null) {%>
        <table class="tableAlumnos" width="100%">
            <thead width="100%">
                <tr>
                    <th width="70%"><center>Descripci&oacute;n</center></th>
                    <th width="20%"><center>Duraci&oacute;n</center></th>
                    <th width="10%"><center><input type="checkbox" name="marcar" onclick="javascript:for(i=0;i<modid.length;i++){modid[i].checked=this.checked}modid.checked=this.checked" /></center></th>
                </tr>
            </thead>
            <tbody>

                <%for (Modulo modulo : listamodulos) {%>
                <tr<%if (linea) {%> class="estilocelda5" <%}
                    linea = !linea;%>>
                    <td><%=Verificador.comprobar(modulo.getModDescr())%></td>
                    <td><center><%=Verificador.comprobar(modulo.getModDuracion())%></center></td>
                    <td><center><input type="checkbox" name="modid" value="<%=modulo.getModId()%>" /></center></td>
                </tr>
                <%}%>
            </tbody>
        </table>
        <%}%>
    </form>
</div>